<template>
    <view class="authentication">
        <view class="top">
            <!-- <image src="../../static/ioncrz@2x.png" class="ioncrz"></image> -->
            <view class="ioncrz">
                
            </view>
            <view class="top-ions">
                <image src="../../static/ionss@2x.png" class="ionss"></image>
                <view class="text">
                    您还未通过实名认证
                </view>
            </view>
            <view class="jiang">
                根据国家相关政策，请尽快完成认证以免 影响您的功能使用
            </view>
        </view>
        <view class="content">
            <view class="title">
                认证信息审核
            </view>
            <view class="content-item" @click="openrenzheng(1)">
                <view class="item-left">
                    实名信息
                </view>
                <view class="item-right">
                    {{is_real?'已认证':'未认证'}}  <image src="../../static/left.png" mode=""></image>
                </view>
            </view>
            <view class="content-item" @click="openrenzheng(2)">
                <view class="item-left">
                    人脸核身
                </view>
                <view class="item-right">
                    {{isHigh?'已认证':'未认证'}} <image src="../../static/left.png" mode=""></image>
                </view>
            </view>
      </view>
      <view class="bottom">
          <view class="titel">
              认证说明
          </view>
          <view class="text">
              根据《中华人民共和国网络安全法》，所有注册用户需使用 有效身份证信息进行登记。  
          </view>
          <view class="text">
              实名信息验证通过后无法修改。为了避免无法提现等问题， 请正确填写本人实名信息。
          </view>
          <view class="text">
              完成初级认证后，可用额度为2000元/月；完成高级认证后 不限额。
          </view>
      </view>
    </view>
</template>

<script>
	import * as userApi from '@/api/user'
	export default{
		data(){
			return{
				is_real: false,
				isHigh: false,
				survey_real:false,
				inquiry:{
					status:null
				},
				is_check:null
			}
		},
		onShow() {
			this.loadDetail1()
			this.loadDetail2()
			// this.is_check = uni.getStorageSync("userInfo").is_check
			// if(this.is_check != 1){
			// 	this.loadDetail3()
			// }
		},
		methods: {
			loadDetail3(){
				return new Promise((resolve,reject) => {
					let user_id = uni.getStorageSync("userInfo").user_id
					let token = uni.getStorageSync("AccessToken")
					userApi.dueDiligenceStatus({
						user_id,
						token
					})
					.then(result => {
						if(result.code === 1){
							this.inquiry = result.data
						}
						resolve(result.data)
					})
				})
			},
			async openSurvey(){
				if(!this.is_real) {
					return this.$toast('请先进行先初级认证')
				}
				await this.loadDetail3()
				if(this.inquiry.status === null){
					uni.navigateTo({
						url:'/pageace_ali/pages/cart/survey_next?type=1'
					})
				}else{
					if(this.inquiry.status === 1){
						return
					}
					uni.navigateTo({
						url:`/pages/user/user_item/real/already?detail=${JSON.stringify(this.inquiry)}`
					})
				}
			},
			loadDetail1() {
				let token = uni.getStorageSync("AccessToken")
				userApi.getUserRealStatus({
					wxapp_id: this.$wxapp_id,
					token:  token,
					type:1
				})
				.then(result => {
					this.is_real = !!result.data.name
				})
			},
			loadDetail2() {
				let token = uni.getStorageSync("AccessToken")
				userApi.getUserRealStatus({
					wxapp_id: this.$wxapp_id,
					token:  token,
					type:2
				})
				.then(result => {
					this.isHigh = !!result.data.name
				})
			},
			openrenzheng(type){
				if(type === 1){
					if(!this.is_real){
						uni.navigateTo({
							url:"/pages/my/real/primary"
						})
					}else{
						uni.navigateTo({
							url:"/pages/user/user_item/real/renzheng-already?type=1"
						})
					}
				}else{
					if(!this.is_real) {
						return this.$toast('请先进行先初级认证')
					}
					if(!this.isHigh) {
						uni.navigateTo({
							url:"/pages/my/real/identification"
						})
					}else{
						uni.navigateTo({
							url:"/pages/user/user_item/real/renzheng-already?type=2"
						})
					}
				}
			},
		}
	}
</script>

<style lang="scss">
    .authentication{
        height: calc(100vh );
        background-color: #F2F7FA;
        .top{
            position: relative;
            padding: 0 32rpx;
             height: 260rpx;
            .ioncrz{
                position: absolute;
                width: 100%;
                height: 260rpx;
                background: url('/static/ioncrz@2x.png') no-repeat ;
                background-size:90% 260rpx ;
                
            }
            .top-ions{
                padding-top: 62rpx;
                margin-left: 48rpx;
                position: relative;
                display: flex;
                .ionss{
                    width: 36rpx;
                    height: 36rpx;
                    margin-right: 16rpx;
                }
                .text{
                    height: 42rpx;
                    font-family: PingFang SC, PingFang SC;
                    font-weight: 600;
                    font-size: 30rpx;
                    color: #FFFFFF;
                    line-height: 35rpx;
                    text-align: left;
                    font-style: normal;
                    text-transform: none;
                }
            }
            .jiang{
                margin-top: 18rpx;
                 margin-left: 48rpx;
                position: relative;
                width: 396rpx;
                height: 60rpx;
                font-family: PingFang SC, PingFang SC;
                font-weight: 400;
                font-size: 22rpx;
                color: #FFFFFF;
                line-height: 26rpx;
                text-align: left;
                font-style: normal;
                text-transform: none;
            }
        }
        .content{
            padding: 0 32rpx;
            padding-top: 34rpx;
            height: 260rpx;
            background: #FFFFFF;
            border-radius: 0rpx 0rpx 0rpx 0rpx;
            .title{
                margin-bottom: 42rpx;
                height: 42rpx;
                font-family: PingFang SC, PingFang SC;
                font-weight: 600;
                font-size: 30rpx;
                color: #333333;
                line-height: 42rpx;
                text-align: left;
                font-style: normal;
                text-transform: none;
            }
            .content-item{
                margin-bottom: 30rpx;
                display: flex;
                justify-content: space-between;
                .item-left{
                    height: 42rpx;
                    font-family: PingFang SC, PingFang SC;
                    font-weight: 400;
                    font-size: 30rpx;
                    color: #333333;
                    line-height: 42rpx;
                    text-align: left;
                    font-style: normal;
                    text-transform: none;
                }
                .item-right{
                    height: 42rpx;
                    font-family: PingFang SC, PingFang SC;
                    font-weight: 400;
                    font-size: 30rpx;
                    color: #333333;
                    line-height: 42rpx;
                    text-align: left;
                    font-style: normal;
                    text-transform: none;
                    image{
                        margin-left: 10rpx;
                      width: 16rpx;
                      height: 24rpx;
                    }
                }
                
            }
        }
        .bottom{
            margin-top: 94rpx;
            padding: 0 32rpx;
            .titel{
                margin-bottom: 22rpx;
                height: 40rpx;
                font-family: PingFang SC, PingFang SC;
                font-weight: 600;
                font-size: 28rpx;
                color: #626566;
                line-height: 40rpx;
                text-align: left;
                font-style: normal;
                text-transform: none;
            }
            .text{
                 margin-bottom: 22rpx;
                font-family: PingFang SC, PingFang SC;
                font-weight: 300;
                font-size: 26rpx;
                color: #626566;
                line-height: 40rpx;
                text-align: left;
                font-style: normal;
                text-transform: none;
            }
        }
        
    }
</style>